#include <stdio.h>

long fac(int n); // 函数原型

int main() {
    int n;
    printf("Input an integer:\n");
    scanf("%d", &n);

    if (n < 0) {
        printf("Input Error!\n");
    } else {
        printf("%d! = %ld\n", n, fac(n));
    }

    return 0;
}

long fac(int n) {
    long result = 1;

    for (int i = 1; i <= n; i++) {
        result *= i;
    }

    return result;
}
